package kuangstudy;

import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author:李雄
 * @create:2022-07-10 21:23
 */
public class TestPool {
    public static void main(String[] args) {

        //创建服务，创建线程池
        //Executors.newFixedThreadPool 参数为：线程大小
        ExecutorService service = Executors.newFixedThreadPool(10);

        //1.执行
        service.execute(new MyThread());
        service.execute(new MyThread());
        service.execute(new MyThread());
        service.execute(new MyThread());

        //2.关闭链接
        service.shutdown();
    }

}

class MyThread implements Runnable {

    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName());
    }
}
